package com.mmall.concurrency.example.syncContainer;

import com.mmall.concurrency.annotions.NotThreadSafes;

import java.util.Vector;

/**
 * <p>Descriptions...
 *
 * @author Diamon.Cheng
 * @date 2019/12/9.
 */
@NotThreadSafes
public class VectorExample_2 {

    private  static Vector<Integer> vector = new Vector<>();
    
    public static void main(String[] args) {
        while (true){
            for (int i= 0 ;i<10; i++){
                vector.add(i);
            }
            
            Thread  thread1 = new Thread(){
                @Override
                public void run(){
            
                    for (int i =0;i<vector.size();i++){
                        vector.remove(i);
                    }
                }
            };
    
            Thread  thread2 = new Thread(){
                @Override
                public void run(){
            
                    for (int i =0;i<vector.size();i++){
                        vector.remove(i);
                    }
                }
            };
            
            thread1.start();
            thread2.start();
        
        }
    
    }
}
